﻿@using QuestionsAnswers.UI.Models
@model QuestionsAnswers.UI.Models.Course
@{
    ViewBag.Title = "Edit";
}
<h2>
    Edit</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Course</legend>
        @Html.HiddenFor(model => model.CourseId)
        @Html.HiddenFor(model => model.Creator.UserName)
        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}
<p>
    @if (@Model.CanModify(User.Identity.Name))
    {  
        @Ajax.ActionLink("Invite New", "InviteMember", "Invitation", new CourseMemberIds { CourseId = Model.CourseId, MemberType = "Participant" }, new AjaxOptions { OnSuccess = "OnSuccessGeneral" })
    }
</p>
<span class="expandDialog expand" style="display: inline-block">Owners</span>
<div class="collapse">
    @Html.Partial("UserPartial", new CoursePass { Users = @Model.Owners, Course = @Model, Editable = @Model.CanModify(User.Identity.Name), MemberType = "Owner" })
</div>
<br />
<span class="expandDialog expand" style="display: inline-block">Participants</span>
<div class="collapse">
    @Html.Partial("UserPartial", new CoursePass { Users = @Model.Participants, Course = @Model, Editable = Model.CanModify(User.Identity.Name), MemberType = "Participants" })
</div>
<div>
    @Html.ActionLink("Back to List", "Index")
</div>
